package com.ncloud.act.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.ncloud.act.entity.PayLog;

@Mapper
public interface PayLogMapper{

	@Select("SELECT charge_id, acct_id, channel_id, payment_id, pay_fee_mode_code, payment_op, recv_fee, recv_user_id, "
			+ "date_format(recv_time, '%Y-%m-%d %H:%i:%s' ) as recv_time, outer_trade_id, outer_pay_no, project_id, contract_inst_id,  "
			+ "cancel_tag, cancel_user_id, date_format(cancel_time, '%Y-%m-%d %H:%i:%s' ) as cancel_time, cancel_charge_id, rsrv_fee1,  "
			+ "rsrv_info1, remark FROM bi_l_paylog where acct_id=#{acctID} order by recv_time desc")
	@Results({
		@Result(column="charge_id",property="charge_id"),@Result(column="acct_id",property="acct_id"),
		@Result(column="channel_id",property="channel_id"),@Result(column="payment_id",property="payment_id"),
		@Result(column="pay_fee_mode_code",property="pay_fee_mode_code"),@Result(column="payment_op",property="payment_op"),
		@Result(column="recv_fee",property="recv_fee"),@Result(column="recv_user_id",property="recv_user_id"),
		@Result(column="recv_time",property="recv_time"),@Result(column="outer_trade_id",property="outer_trade_id"),
		@Result(column="outer_pay_no",property="outer_pay_no"),@Result(column="project_id",property="project_id"),
		@Result(column="contract_inst_id",property="contract_inst_id"),@Result(column="cancel_tag",property="cancel_tag"),
		@Result(column="cancel_user_id",property="cancel_user_id"),@Result(column="cancel_time",property="cancel_time"),
		@Result(column="cancel_charge_id",property="cancel_charge_id"),@Result(column="rsrv_fee1",property="rsrv_fee1"),
		@Result(column="rsrv_info1",property="rsrv_info1"),@Result(column="remark",property="remark")})
	List<PayLog> getPayLogByAcctID(Long acctID);

	@Insert(value = "insert into bi_l_paylog(charge_id, acct_id, channel_id, payment_id, pay_fee_mode_code, payment_op, recv_fee, recv_user_id, recv_time, outer_trade_id, outer_pay_no, project_id, contract_inst_id, cancel_tag, cancel_user_id, cancel_charge_id, rsrv_fee1, rsrv_info1, remark) "
			+ "values(#{charge_id},#{acct_id},#{channel_id},#{payment_id},#{pay_fee_mode_code},#{payment_op},#{recv_fee},#{recv_user_id},#{recv_time},#{outer_trade_id},#{outer_pay_no},#{project_id},#{contract_inst_id},#{cancel_tag},#{cancel_user_id},#{cancel_charge_id},#{rsrv_fee1},#{rsrv_info1},#{remark})")
    public int insertPayLog(PayLog payLog);
}
